package com.cttq.dubbo.consumer.demos.web;

import org.apache.dubbo.config.annotation.DubboReference;
import org.example.User;
import org.example.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author <a href="https://blog.qinghuan.fun/index.php/go/gu/">Mr_Gu</a>
 * @apiNote
 * @date 2024-04-11 09:04
 * @since
 **/
@RestController
public class UserController {

    @DubboReference(registry = "demoapi", version = "${dubbo.registries.demoapi.version}")
    private UserService userService;

    @RequestMapping("/hello")
    public String hello(@RequestParam(name = "id", defaultValue = "1") String id) {
        User user = userService.getUser(id);
        return "Hello " + user.getName();
    }

}
